﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using GeneralClasses;
using Algorithm;

namespace Algorithm
{
    public static class Algorithm
    {
        public static float FitnessFunction(int[] schedule)
        {
            return 0.0f;
        }

        /// <summary>
        /// Preconditions: None.
        /// Postconditions: Returns a float value representing how well the schedule meets the hard constraints.
        /// </summary>
        public static float HeuristicAlgorithm(int[] schedule, ScheduleData scheduleData,  Constraint[] hardConstraints)
        {
            float score = 0.0f;

            foreach (Constraint hardConstraint in hardConstraints)
                score += hardConstraint.Evaluate();

            return score;
        }

        public static float GeneticAlgorithm(int[] schedule, ScheduleData scheduleData, Constraint[] softConstraints)
        {
            return 0.0f;
        }

        internal static int GetNumScheduleBlocksPerDay(int[] schedule, ScheduleData scheduleData)
        {
            int scheduleBlocks = 0;

            for (int i = 0; i < scheduleData.Departments.Count * scheduleData.Shifts.Count; i++)
                scheduleBlocks += scheduleData.GetNumNursesPerDepartment(i);

            return scheduleBlocks;
        }

        internal static int GetDay(int[] schedule, ScheduleData scheduleData, int index)
        {
            return (int)Math.Floor((double)index / GetNumScheduleBlocksPerDay(schedule, scheduleData));
        }

        internal static int GetDepartment(int[] schedule, ScheduleData scheduleData, int index)
        {
            int subIndex = index - (GetDay(schedule, scheduleData, index) * GetNumScheduleBlocksPerDay(schedule, scheduleData));
            return subIndex / scheduleData.Departments.Count;
        }

        internal static List<Shift> GetShifts(int[] schedule, ScheduleData scheduleData, int nurseID)
        {
            List<Shift> shifts = new List<Shift>();

            for (int i = 0; i < schedule.Length; i++)
            {
                if (schedule[i] == nurseID)
                {
                }
            }

            return shifts;
        }
    }
}
